class Stu {
    constructor(clazz, name, gender, age, hobby, tel, address, remark) {
        this.clazz = clazz;
        this.name = name;
        this.gender = gender;
        this.age = age;
        this.hobby = hobby;
        this.tel = tel;
        this.addStudent = address;
        this.remark = remark;
    }
}
function addStudent() {
    // 班级
    let clazz = document.getElementById("class").value;
    // 名字
    let name = document.getElementById("name").value;
    // 性别
    let radio = document.getElementsByName("sex")[0].checked;
    var radiovalue;
    if (radio == true) {
        radiovalue = "男"
    } else {
        radiovalue = '女'
    }
    // 年龄
    let age = document.getElementById("age").value;
    // 爱好
    let checkboxarr = document.getElementsByName("aihao");
    let selectchecked = [];

    for (let i = 0; i < checkboxarr.length; i++) {
        if (checkboxarr[i].checked == true) {
            selectchecked.push(checkboxarr[i].value);
        }
    }
    // 手机号
    let tel = document.getElementById("tel").value;
    // 地址
    let selectlist = document.getElementById("address");
    let optionlist = selectlist.getElementsByTagName("option");
    let address;
    for (let i = 0; i < optionlist.length; i++) {
        if (optionlist[i].selected == true) {
            address = optionlist[i].value;
        }
    }
    console.log(address);
    console.log(selectchecked);

    // 备注
    let beizhu = document.getElementById("beizhu").value;
    // let date = document.getElementById("date").value;
    // console.log(date);
    // let stu = new Stu(clazz, name, radiovalue, age, selectchecked, tel, address, beizhu);

    let add = postAjax("http://localhost:3008/api/student/addStudent", `clazz=${clazz}&name=${name}&gender=${radiovalue}&age=${age}&hobby=${selectchecked}&tel=${tel}&address=${address}&remark=${beizhu}`);
    add.then((data) => {
        alert("添加成功");

    }).catch(data => {
        alert("添加成功");

    })



}


